package com.freewater.springboot.demo.validation.baseuse;

import com.freewater.springboot.demo.validation.ValidatorUtil;

import jakarta.validation.ConstraintViolation;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        User user = new User();
        user.setPassword("123");
        user.setAge(-1);
        user.setEmail("not email");
        user.setMobile("456");

        List<Subject> subjects = new ArrayList<>();
        subjects.add(new Subject());
        subjects.add(new Subject());
        user.setSubjectList(subjects);

        final Set<ConstraintViolation<User>> violations = ValidatorUtil.validate(user);
        for (ConstraintViolation<User> violation : violations) {
            System.out.println(violation.getMessage());
        }
    }
}
